package com.softeem.music_sys.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.softeem.music_sys.service.AdminService;
import com.softeem.music_sys.entity.Admin;
import com.softeem.music_sys.mapper.AdminMapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;

@Service
public class AdminServiceImpl extends ServiceImpl<AdminMapper,Admin> implements AdminService {


    @Override
    public boolean add(Admin admin) {
        //根据提供的账号名查询是否存在重复的管理员
        //创建查询条件包装器 构建sql查询条件的工具类
        QueryWrapper<Admin> query = Wrappers.query(Admin.class);
        //eq:equals 相等      ne:not equals 不相等       gt:greater than 大于  lt:less than 小于
        query.eq("username", admin.getUsername());
        Admin a = getOne(query);
        if (a != null) {
            //账号已存在
            return false;
        }
        //执行添加
        return save(admin);
    }
    @Override
    public boolean login(String username, String password) {
        return false;
    }
}
